package com.ocom.aiotweb.service.impl;

import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.ocom.aiotweb.feignclient.AiotClientService;
import com.ocom.aiotweb.service.ParamsInfoService;
import com.ocom.aiotweb.vo.paramsinfo.GetFieidNoNameListVo;
import com.ocom.aiotweb.vo.paramsinfo.GetSaasNameListVo;
import com.ocom.common.entity.aiot.EntitySaasInfo;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ParamsInfoServiceImpl implements ParamsInfoService {

    @Autowired
    private AiotClientService aiotClientService;

    // 参数信息 信息列表（paramsInfo/onShow）
    @Override
    public Result ParamsInfoOnShow() {

        Result result = aiotClientService.GetSaasNameList(null, null);
        if(result.getCode()!=200){
            return ResultUtil.error(result.getCode());
        }


        String fieldName = "xf_device_info.device_ver_type";
        Result result1 = aiotClientService.GetFieidNoNameList(fieldName);
        if(result1.getCode()!=200){
            return ResultUtil.error(result1.getCode());
        }
       fieldName = "user_info.user_type";
        Result result2 = aiotClientService.GetFieidNoNameList(fieldName);
        if(result2.getCode()!=200){
            return ResultUtil.error(result2.getCode());
        }

        Map<String, Object> map = new HashMap<>();
        map.put("saasList",result.getData());
        map.put("deviceTypeList",result1.getData());
        map.put("userTypeList",result2.getData());
        return ResultUtil.success(map);
    }
}
